#----------------------------
# Name: Conor McGuire
# Project: Madlibs.py
# Period: 2
# Start Date: 9/17/2013
# Last Revision Date: 9/17/2013
# Version: 1.0.0
#----------------------------

swearFilter = ["dumb",
               "stupid",
               "retard",
               "fuck", 
               "cunt", 
               "faggot", 
               "nigger",
               "fag",
               "dick",
               "ass",
               "asshole",
               "bitch",
               "damn",
               "vag",
               "asshole",
               "Nigger dick slut",
               "shit",
               "cock",
               "fisted",
               "rape",
               "raped",
               "shat",
               "fucked",
               "fucking",
               "fucker",
               "fuckers",
               "anal",
               "potato",
               "Potato",
               "POTATO",
               "Penisland",
               "penisland",
               "banged",
               "dildo",]
               

def displayStartScreen():
    print "Madlibs"
    raw_input("Press Enter to Continue")
    
def displayEndScreen():
    print "Goodbye"
    raw_input("Press Enter to Exit")

def getMenuOption(maxOption):
    option = ""
    goodOption = False
    while not goodOption:
        option = raw_input("Enter Number or Q> ")
        option = option.upper()
        for num in range(1, maxOption+2):
            if option == str(num):
                goodOption = True
        if option == 'Q':
            goodOption = True
        if not goodOption:
            print "Please pick a valid option!"
    return option
        
def menu(options):
    print "------Please Select a Story------"
    print " [1] The Adventures of Jack Shock"
    print " [2] The Morning After"
    print " [3] Jack's Tales From Jail"
    print " [Q] Quit"
    print "----------------------------------"
    option = getMenuOption(options)
    return option
    
def getWord(prompt):
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        if word.lower() not in swearFilter:
            goodWord = True
        else:
            print "Naughty player...please be polite."
        if not goodWord:
            print "Try again"
    return word
    
def getNumber(prompt, max = "", min = ""):
    num = ""
    goodNum = False
    while not goodNum:
        isNum = True
        num = raw_input(prompt)
        for character in num:
            if character not in "0123456789":
                isNum = False
        if min != "":
            if isNum:
                if float(num) < min:
                    isNum = False
        if max != "":
            if isNum:
                if float(num) > max:
                    isNum = False
        if isNum:
            goodNum = True
        else:
            print "Not a valid number, try again."
    return num
        
def story1():
    place1 = getWord("Enter a place: ")
    action = getWord("Enter a past tense action: ")
    object = getWord("Enter an object: ")
    place2 = getWord("Enter an place: ")
    action2 = getWord("Enter a past tense action: ")
    action3 = getWord("Enter an action not ending in 'ing: ")
    name = getWord("Enter a name: ")
    adjective = getWord("Enter an adjective: ")
    noun = getWord("Enter a plural noun: ")
    game = getWord("Enter the name of a game: ")
    time = getWord("Enter a time: ")
    story = "Jack Shock woke up in the middle of"
    story += " " + place1 + ". He "
    story += " " + action + " a "
    story += " " + object + ". He "
    story += " " + action2 + " down to "
    story += " " + place2 + ". When he got there he decided he wanted to"
    story += " " + action3 + ". When he finished " + action3 + "ing he met up with his friend named"
    story += " " + name + ". " + name + " was very"
    story += " " + adjective + " and did not like"
    story += " " + noun + ". Jack and " + name + " spent the rest of the day playing"
    story += " " + game + " until they finally went to sleep at"
    story += " " + time + ". The End."
    print story
    
def story2():
    adjective = getWord("Enter an adjective: ")
    time = getWord("Enter a time: ")
    adjective2 = getWord("Enter an adjective: ")
    number = getNumber ("Enter a positive integer: ")
    noun = getWord ("Enter a noun: ")
    adjective3 = getWord ("Enter an adjective: ")
    adjective4 = getWord ("Enter an adjective: ")
    noun2 = getWord ("Enter a noun: ")
    adjective5 = getWord ("Enter an adjective: ")
    noun3 = getWord ("Enter a noun: ")
    story = "Jack Shock woke up from his"
    story += " " + adjective + " sleep at"
    story += " " + time + ". It was the morning after he went on his"
    story += " " + adjective2 + " adventures. He woke up and there were"
    story += " " + number + " " 
    story += " " + noun + "s there. He had no idea how the " + noun + "s got there. One of the " + noun + "s told Jack that the party at Jacks house the previous night was"
    story += " " + adjective3 + ". Jack told the " + noun + " that there was no party at his house the previous night. Jack and the " + noun + " got into a"
    story += " " + adjective4 + " "
    story += " " + noun2 + " fight. Jack killed the " + noun + " with a"
    story += " " + adjective5 + " "
    story += " " + noun3 + ". The End."
    print story
    
def story3():
    adjective = getWord ("Enter an adjective: ")
    place = getWord ("Enter a place: ")
    adjective2 = getWord ("Enter an adjective: ")
    outcome = raw_input("CHOOSE JACK'S FATE! Enter good or bad: ")
    if outcome == 'good':
        adjective3 = getWord ("Enter an adjective: ")
    if outcome == 'bad':
        adjective4 = getWord ("Enter an adjective: ")
        bodypart = getWord ("Enter a body part: ")
        verb = getWord ("Enter a past tense verb: ")
        adjective5 = getWord ("Enter an adjective: ")
        noun = getWord ("Enter a noun: ")
        number = getNumber ("Enter a number: ")
        number2 = getNumber ("Enter a number: ")
    story = "Jack Shock woke up from his"
    story += " " + adjective + " sleep. He was in a cell in the middle of the"
    story += " " + place + " County Jail. Jack was arrested and taken to jail for his" 
    story += " " + adjective2 + " actions the previous night." 
    print story
    if outcome == 'good':	
        story = "Jack decided he was going to try and escape from the"
        story += " " + adjective3 + " jail."
    if outcome == 'bad':
        story = "Jack did not like it in the"
        story += " " + adjective4 + " jail. He get his"
        story += " " + bodypart + " " + verb + " by a"
        story += " " + adjective5 + " " + noun + "" 
        story += " " + number +  " times a day. This happened every day until he died at age"
        story += " " + number2 + ". The End."
    print story
    
def run():
    displayStartScreen()
    choice = ""
    while choice != 'Q':
        choice = menu(2)
        if choice == '1':
            story1()
        elif choice == '2':
            story2()
        elif choice == '3':
            story3()
        elif choice == 'Q':
            displayEndScreen()
        else:
            print "Something Awful Ocurred...yell at programmer!"
    exit()
run()